<template>
  <div class="home">
    <van-notice-bar text="如有任何问题不要退款，请联系加客服群：1051094300"/>
    <div class="home_bg" v-if="bgshow"></div>
    <div v-else>
      <div class="apply">
        <span class="apply_text" v-show="tasktatus.task_status == 2" @click="oncancel">取消活动</span>
        <span class="apply_text" @click="onApply" v-show="tasktatus.task_status != 2">申请活动</span>
        <div
          style="width:200px;height:25px;border:1px solid #bababa;display:flex;justify-content:center;align-items:center;border-radius:10px;margin:0 auto;margin-top:50px;">
          <span v-show="checks == 'tb'">旺旺号：{{ taobao_name }}</span>
          <span v-show="checks == 'dy'">抖音号：{{ dy_actives }}</span>
        </div>
        <div class="blocked" style="margin-top:10px;" v-show="checks == 'dy'">
          <div class="left_btn same btn" :class="{active:act == 1}" @click="clickBtn(1)">淘宝活动</div>
          <div class="right_btn same btn" :class="{active:act == 2}" @click="clickBtn(2)">抖音活动</div>
        </div>
        <div class="blocked" style="margin-top:10px;" v-show="checks == 'tb'">
          <div class="left_btn same btn" :class="{active:act == 1}" @click="clickBtn(1)">淘宝活动</div>
          <div class="right_btn same btn" :class="{active:act == 2}" @click="clickBtn(2)">抖音活动</div>
        </div>
        <el-card style="width:90%;margin:10px auto" class="listbox" v-for="(item,index) in listdata" :key="index">
          <p class="title">
            <span style="font-size:16px;color:red;">{{ item.top }}</span>
          </p>
          <span style="font-size:14px;color:red;" v-html="item.content"></span>
        </el-card>
        <van-tabs v-show="checks == 'dy'" v-model="activing" @change="actives" color="#01abfd"
                  style="margin-top:10px;margin-bottom:60px;overflow-y:scroll;">
          <van-tab :title="dy_one">
            <div class="bigcard">
              <div class="card">
                <div v-if="isshow">
                  <span class="task">您当前的活动已被领完，下一波</span>
                </div>
                <span v-else class="task">当前的活动数量为<span class="special">10</span>个,下一波</span>
                <span class="task">活动来临时间为 <span
                  class="special">{{
                    new Date().getFullYear() + '-' + (new Date().getMonth() + 1) + '-' + new Date().getDate()
                  }} {{ new Date().getHours() + 1 + ":00:00" }}</span></span>
                <span class="task">活动数量为<span
                  class="special">210</span>个，请提前做好准备哦~</span>
              </div>
            </div>
          </van-tab>
          <van-tab :title="dy_two">
            <div class="bigcard">
              <div class="card">
                <div v-if="isshow">
                  <span class="task">您当前的活动已被领完，下一波</span>
                </div>
                <span v-else class="task">当前的活动数量为<span class="special">10</span>个,下一波</span>
                <span class="task">活动来临时间为 <span
                  class="special">{{
                    new Date().getFullYear() + '-' + (new Date().getMonth() + 1) + '-' + new Date().getDate()
                  }} {{ new Date().getHours() + 1 + ":00:00" }}</span></span>
                <span class="task">活动数量为<span
                  class="special">210</span>个，请提前做好准备哦~</span>
              </div>
            </div>
          </van-tab>
          <van-tab :title="dy_three">
            <div class="bigcard">
              <div class="card">
                <div v-if="isshow">
                  <span class="task">您当前的活动已被领完，下一波</span>
                </div>
                <span v-else class="task">当前的活动数量为<span class="special">10</span>个,下一波</span>
                <span class="task">活动来临时间为 <span
                  class="special">{{
                    new Date().getFullYear() + '-' + (new Date().getMonth() + 1) + '-' + new Date().getDate()
                  }} {{ new Date().getHours() + 1 + ":00:00" }}</span></span>
                <span class="task">活动数量为<span
                  class="special">210</span>个，请提前做好准备哦~</span>
              </div>
            </div>
          </van-tab>
          <van-tab :title="dy_four">
            <div class="bigcard">
              <div class="card">
                <div v-if="isshow">
                  <span class="task">您当前的活动已被领完，下一波</span>
                </div>
                <span v-else class="task">当前的活动数量为<span class="special">10</span>个,下一波</span>
                <span class="task">活动来临时间为 <span
                  class="special">{{
                    new Date().getFullYear() + '-' + (new Date().getMonth() + 1) + '-' + new Date().getDate()
                  }} {{ new Date().getHours() + 1 + ":00:00" }}</span></span>
                <span class="task">活动数量为<span
                  class="special">210</span>个，请提前做好准备哦~</span>
              </div>
            </div>
          </van-tab>
          <van-tab :title="dy_five">
            <div class="bigcard">
              <div class="card">
                <div v-if="isshow">
                  <span class="task">您当前的活动已被领完，下一波</span>
                </div>
                <span v-else class="task">当前的活动数量为<span class="special">10</span>个,下一波</span>
                <span class="task">活动来临时间为 <span
                  class="special">{{
                    new Date().getFullYear() + '-' + (new Date().getMonth() + 1) + '-' + new Date().getDate()
                  }} {{ new Date().getHours() + 1 + ":00:00" }}</span></span>
                <span class="task">活动数量为<span
                  class="special">210</span>个，请提前做好准备哦~</span>
              </div>
            </div>
          </van-tab>
        </van-tabs>
        <van-tabs v-show="checks == 'tb'" v-model="activing_tb" @change="active_tb" color="#01abfd"
                  style="margin-top:10px;margin-bottom:60px;overflow-y:scroll;">
          <van-tab :title="tb_one">
            <div style="margin-top:10px;margin-bottom:60px;">
              <div class="bigcard">
                <div class="card">
                  <el-tag type="danger" @click="ChangeWW()">换旺旺号</el-tag>
                  <span class="task" style="font-size:18px;">需要换旺旺的，你点击哪个就换哪个.</span>
                  <span class="task" style="font-size:18px;">如果接不到任务换淘宝号接</span>
                </div>
              </div>
            </div>
          </van-tab>
          <van-tab :title="tb_two">
            <div style="margin-top:10px;margin-bottom:60px;">
              <div class="bigcard">
                <div class="card">
                  <el-tag type="danger" @click="ChangeWW()">换旺旺号</el-tag>
                  <span class="task" style="font-size:18px;">需要换旺旺的，你点击哪个就换哪个.</span>
                  <span class="task" style="font-size:18px;">如果接不到任务换淘宝号接</span>
                </div>
              </div>
            </div>
          </van-tab>
          <van-tab :title="tb_three">
            <div style="margin-top:10px;margin-bottom:60px;">
              <div class="bigcard">
                <div class="card">
                  <el-tag type="danger" @click="ChangeWW()">换旺旺号</el-tag>
                  <span class="task" style="font-size:18px;">需要换旺旺的，你点击哪个就换哪个.</span>
                  <span class="task" style="font-size:18px;">如果接不到任务换淘宝号接</span>
                </div>
              </div>
            </div>
          </van-tab>
          <van-tab :title="tb_four">
            <div style="margin-top:10px;margin-bottom:60px;">
              <div class="bigcard">
                <div class="card">
                  <el-tag type="danger" @click="ChangeWW()">换旺旺号</el-tag>
                  <span class="task" style="font-size:18px;">需要换旺旺的，你点击哪个就换哪个.</span>
                  <span class="task" style="font-size:18px;">如果接不到任务换淘宝号接</span>
                </div>
              </div>
            </div>
          </van-tab>
          <van-tab :title="tb_five">
            <div style="margin-top:10px;margin-bottom:60px;">
              <div class="bigcard">
                <div class="card">
                  <el-tag type="danger" @click="ChangeWW()">换旺旺号</el-tag>
                  <span class="task" style="font-size:18px;">需要换旺旺的，你点击哪个就换哪个.</span>
                  <span class="task" style="font-size:18px;">如果接不到任务换淘宝号接</span>
                </div>
              </div>
            </div>
          </van-tab>
        </van-tabs>
      </div>
      <van-popup v-model="showwait" round>
        <div class="popupbox">
          <p class="waittext">正在排队申请活动中...</p>
          <img src="../assets/img/wait.jpg" alt="">
          <div class="btnlist">
            <p class="cancel" @click="oncancel">取消排队</p>
            <p class="cancel" style="background:red;" @click="showwait = false">后台排队</p>
          </div>
        </div>
      </van-popup>
      <van-popup v-model="showready" round :close-on-click-overlay="false">
        <div class="popupbox">
          <p class="icon">
            <van-icon name="checked"/>
          </p>
          <p class="isok">您已申请到活动，请领取活动前往活动进度！</p>
          <p class="cancel" @click="ondraw">领取活动</p>
        </div>
      </van-popup>
      <van-popup v-model="user_status" round :close-on-click-overlay="false">
        <div class="popupbox">
          <p class="icon">
            <van-icon name="checked"/>
          </p>
          <p class="isok" style="width:235px;">请先完善信息，审核过后即可接单</p>
          <p class="cancel" @click="$router.push('/uploadImg')">立即完善</p>
        </div>
      </van-popup>
      <van-popup v-model="reminds" round :close-on-click-overlay="false">
        <div class="popupbox" style="text-align: center;">
          <p class="icon">
            <van-icon name="checked"/>
          </p>
          <p class="isok" style="width:235px;">1，点击开启提醒按钮</p>
          <p class="isok" style="width:235px;">2，关注公众号</p>
          <p class="cancel" @click="remindes()">开启提醒</p>
        </div>
      </van-popup>
      <van-popup v-model="showshadow_" round :close-on-click-overlay="false">
        <div class="shadow_">
          <button class="startBtn_yes" @click="queren_()">确认</button>
        </div>
      </van-popup>
      <van-popup v-model="showshadow" round :close-on-click-overlay="false">
        <div class="shadow">
          <button class="startBtn_yes" @click="queren()">确认</button>
        </div>
      </van-popup>
      <!--        公告提醒-->
<!--      <van-dialog v-model="Dialogsssss" title="公告提醒">-->
          <!--          <div style="margin-left:30px;" @click="freachs()">-->
          <!--            <van-button type="primary" size="small">刷新</van-button>-->
          <!--            <span style="font-size:14px;">确认按钮没反应，则点击刷新重新确认</span>-->
          <!--            <p style="color:red;font-weight:600;margin-top:10px;">点击 "确认" 是为了给大家推送接单通知</p>-->
          <!--            <p style="color:red;font-weight:600;margin-top:10px;">务必每一次点击确认则可以收到通知</p>-->
          <!--          </div>-->
        <!--        <div class="wx-open-subscribe-container" v-show="marks == 1">-->
        <!--          <wx-open-subscribe :template="templateId" id="subscribe-btn" class="waters"-->
        <!--                             style=""-->
        <!--                             @success="openSubscribeSuccess">-->
        <!--            <script type="text/wxtag-template">-->
        <!--              <style>.btn {-->
        <!--                color: white;-->
        <!--                background: #2e4eca;-->
        <!--                width: 100px;-->
        <!--                margin: 0 auto;-->
        <!--                height: 40px;-->
        <!--                border-radius: 5px;-->
        <!--                display: flex;-->
        <!--                align-items: center;-->
        <!--                justify-content: center;-->
        <!--                border: 1px solid #1989fa;-->
        <!--              }</style>-->
        <!--              <div class="btn" @click="getacc">确认</div>-->
        <!--            </script>-->
        <!--          </wx-open-subscribe>-->
        <!--        </div>-->
        <!--        <div v-show="marks == 2">-->
        <!--          <van-button style="color:white;-->
        <!--                          background: #2e4eca;-->
        <!--                          width: 100px;-->
        <!--                          margin:10px auto;-->
        <!--                          height: 40px;-->
        <!--                          border-radius:5px;-->
        <!--                          display: flex;-->
        <!--                          align-items: center;-->
        <!--                          justify-content: center;-->
        <!--                          border: 1px solid #1989fa;" @click="iosmark()">确认-->
        <!--          </van-button>-->
        <!--        </div>-->
        <!--        <div v-show="marks == 3">-->
        <!--          <van-button style="color:white;-->
        <!--                          background: #2e4eca;-->
        <!--                          width: 100px;-->
        <!--                          margin:10px auto;-->
        <!--                          height: 40px;-->
        <!--                          border-radius:5px;-->
        <!--                          display: flex;-->
        <!--                          align-items: center;-->
        <!--                          justify-content: center;-->
        <!--                          border: 1px solid #1989fa;" @click="Dialogsssss = false">确认-->
        <!--          </van-button>-->
        <!--        </div>-->
<!--      </van-dialog>-->
<!--      订阅提醒-->
      <van-dialog v-model="Dialog" title="订阅提醒" :showConfirmButton="false"
                  @confirm="Dialogsssss = false;Dialog = false">
        <div style="display:flex;justify-content: center;align-items: center;flex-direction: column;">
          <br/>
          <p style="font-size:20px;color:red;font-weight:600">请在微信搜索公众号:"这一根葱"</p>
          <p style="font-size:20px;color:red;font-weight:600">首页进去点击确认完成以下操作</p>
          <p style="font-size:20px;color:red;font-weight:600">以后只能在微信里面做单</p>
          <p style="font-size:20px;color:red;font-weight:600">⬇</p>
          <br/>
          <img src="../assets/marks.png" style="width:100%;" alt="">
        </div>
      </van-dialog>
<!--      绑定多问旺旺-->
      <van-dialog v-model="tb_dialog" show-cancel-button title="绑定多旺旺"
                  @confirm="register_wws">
        <div
          style="width:100%;display:flex;flex-direction:column;height:300px;margin-top:5%;">
          <van-field v-model="ww_name" label="旺旺号" placeholder="请输入旺旺号"/>
          <br/>
          <div style="display:flex;flex-direction:column;width:70%;margin-left:20px;">
            <div style="display:flex;">
              <p style="font-size:14px;margin-bottom:20px;">旺旺号截图：</p>
                <span style="font-size:14px;font-weight:600;color:red;" @click="img_dialog = true">查看提交图</span>
            </div>
            <el-upload
              class="upload-demo"
              :headers="imgheader"
              list-type="picture"
              action="/api/v1/register/dyimage_recognition"
              :on-success="handlesuccess">
              <el-button size="small" type="primary">点击上传</el-button>
            </el-upload>
          </div>
        </div>
      </van-dialog>
      <van-dialog v-model="ALIplay" title="提交资料" show-cancel-button @confirm="resetAliInfos">
        <van-field v-model="userphone" type="tel" label="手机号" placeholder="请输入手机号"/>
        <van-field v-model="usersms" center clearable label="短信验证码" placeholder="请输入短信验证码">
          <van-button slot="button" size="small" type="info" :disabled="disabled" @click="onMessage">{{btnTitle}}</van-button>
        </van-field>
        <van-field v-model="aliplay" type="tel" label="支付宝账号" placeholder="请输入支付宝账号"/>
      </van-dialog>
      <van-dialog v-model="img_dialog">
        <img src="../assets/wwname.png" style="width:100%;" alt="">
      </van-dialog>
      <van-dialog v-model="ChangeWang" title="提交换旺旺" show-cancel-button @confirm="onSubmit">
        <van-form>
          <van-field
            v-model="OldWW"
            disabled
            name="旧旺旺"
            label="旧旺旺"
            placeholder="旧旺旺"
          />
          <van-field
            v-model="NewWW"
            name="新旺旺"
            label="新旺旺"
            placeholder="新旺旺"
          />
        </van-form>
      </van-dialog>
      <returnone></returnone>
      <Footer></Footer>
    </div>
  </div>
</template>

<script>
import {
  submessage,
  getuserstatus,
  cancelqueue,
  bulletin_list,
  update_ww_name,
  prompttask,
  resetAliInfo,
  register_ww,
  taskMessageSign,
  getuserinfo,
  taskprogress,
  reminder_no,
  remindaddress,
  dy_user_list,
  dy_sub_message, sendcode, identifytask,
} from '../api/api';
import Footer from '../components/footer.vue'
import aestool from '@/utils/aestool.js';
import AgainReturn from "./AgainReturn";
import Returnone from "./returnone";
import wx from "weixin-js-sdk";

export default {
  components: {Returnone, AgainReturn, Footer},
  inject: ['reload'],
  data() {
    return {
      disabled:false,
      ChangeWang:false,
      OldWW:"",
      NewWW:"",
      userphone:"",
      aliplay:"",
      usersms:"",
      btnTitle:"获取验证码",
      ww_name: "",
      ALIplay:false,
      img_dialog:false,
      taskClass: window.localStorage.getItem('xfq_task_class'),
      imgheader: {token: window.localStorage.getItem('xfq_token')},
      templateId: "",
      tb_dialog: false,
      listdata: [],
      page: 0,
      tb_one: "",
      tb_two: "",
      tb_three: "",
      tb_four: "",
      tb_five: "",
      activing_tb: 0,
      loading: false,
      finished: false,
      activing: 1,
      Dialogsssss: false,
      checks: "tb",
      dy_one: "",
      dy_two: "",
      dy_three: "",
      dy_four: "",
      dy_five: "",
      dy_actives: "",
      act: 1,
      taobao_name: "",
      showwait: false,
      showshadow_: false,
      user_status: false,
      showready: false,
      dialog: '',
      showshadow: false,
      dialogVisible: false,
      tasktatus: '',
      timer: '',
      count: '',
      showing: false,
      isshow: false,
      redisnum: '',
      userinfodata: {},
      dy_acount: [],
      bgshow: false,
      reminds: false,
      counting: 0,
      templates: {},
      evareview_info: [],
      marks: 1,
      wwimg:"",
      Dialog: false,
      taskdata:{},
    }
  },
  created() {
    // this.getsliss()
    this.getUserData()
    this.getStatus()
    this.dy_user_lists()
    this.onLoad()
  },
  methods: {
    ChangeWW(){
        this.ChangeWang = true
        this.OldWW = this.taobao_name
    },
    onSubmit(){
      let params = {
        ww_name:this.NewWW,
        old_tb_name:this.OldWW,
      }
      update_ww_name(params).then((res)=>{
        if(res.Status == 200){
           this.$toast(res.Message)
        }else{
          this.$toast(res.Message)
        }
      })
    },
    //发送验证码
    onMessage(){
      //判断输入的手机号是否合法
      if(!this.userphone) {
        this.$toast("手机号码不能为空")
      } else if(!/^1[3456789]\d{9}$/.test(this.userphone)) {
        this.$toast("请输入正确是手机号")
      }else{
        //倒计时
        let time = 60;
        let timer = setInterval(() => {
          if(time == 0) {
            clearInterval(timer);
            this.disabled = false;
            this.btnTitle = "获取验证码";
          } else {
            this.btnTitle =time + '秒后重试';
            this.disabled = true;
            time--
          }
        },1000)
        let params = {
          phone:aestool.encrypt(this.userphone,'123456asdzxcqwe0')
        }
        sendcode(params).then(res=>{
          console.log('验证码',res)
          if(res.Status == 200){
            this.$toast('发送成功！')
          }else{
            this.$toast(res.Message)
          }
        })
      }
    },
    resetAliInfos(){
      let params = {
        code:aestool.encrypt(this.usersms,"OldphoneResetAli"),
        phone:aestool.encrypt(this.userphone,"OldphoneResetAli"),
        new_ali:aestool.encrypt(this.aliplay,"OldphoneResetAli")
      }
      resetAliInfo(params).then((res)=>{
        console.log(res);
        if(res.Status == 200){
           this.ALIplay = false
           this.$toast(res.Message)
        }else{
          this.$toast(res.Message)
        }
      })
    },
    handlesuccess(res) {
      this.wwimg = res.UrlImg
    },
    register_wws() {
      let params = {
        ww_name: this.ww_name,
        wwimg: this.wwimg,
      }
      register_ww(params).then((res) => {
        console.log(res);
        if(res.Status == 200){
           this.$toast(res.Message)
        }else{
          this.$toast(res.Message)
        }
      })
    },
    active_tb(val, name) {
      if (name != '未绑定淘宝号') {
        this.taobao_name = name
        console.log(this.taobao_name);
      } else {
        this.tb_dialog = true
      }
    },
    iosmark() {
      this.Dialog = true
    },
    freachs() {
      this.$router.go(0)
    },
    getsliss() {
      let browser = {
        versions: function () {
          let u = navigator.userAgent, app = navigator.appVersion;
          return {         //移动终端浏览器版本信息
            trident: u.indexOf('Trident') > -1, //IE内核
            presto: u.indexOf('Presto') > -1, //opera内核
            webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
            gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
            mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
            ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
            android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或uc浏览器
            iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
            iPad: u.indexOf('iPad') > -1, //是否iPad
            webApp: u.indexOf('Safari') == -1 //是否web应该程序，没有头部与底部
          };
        }(),
        language: (navigator.browserLanguage || navigator.language).toLowerCase()
      }
      if (browser.versions.mobile) {//判断是否是移动设备打开。browser代码在下面
        let ua = navigator.userAgent.toLowerCase();//获取判断用的对象
        if (browser.versions.android && ua.match(/MicroMessenger/i) == "micromessenger") {
          //是否在安卓浏览器打开
          this.Dialogsssss = false
          console.log(this.marks, '1');
          return
        }
        if (ua.match(/MicroMessenger/i) == "micromessenger") {
          this.marks = 1
          console.log(this.marks, '2');
        } else {
          console.log(this.marks, '3');
          this.marks = 2
        }
        if (ua.match(/QQ/i) == "qq") {
          //在QQ空间打开
          this.marks = 2
          console.log(this.marks, '4');
        }
      } else {
        this.marks = 3
        console.log(this.marks, '5');
        //否则就是PC浏览器打开
      }
    },
    openSubscribeSuccess() {
      let toastload = this.$toast.loading({
        message: '加载中...',
        forbidClick: true,
        duration: 1000,
      });
      setInterval(() => {
        toastload.clear()
        this.Dialogsssss = false
      })
    },
    getacc() {
      taskMessageSign().then((res) => {
        this.templates = JSON.parse(aestool.decrypt(res.Data, "TaskMessageSign1"))
        this.templateId = this.templates.dyOrderTemplate
        console.log(this.templates.signature, '前面');
        wx.config({
          debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印
          appId: this.templates.appId, // 必填，公众号的唯一标识
          timestamp: this.templates.timestamp, // 必填，生成签名的时间戳
          nonceStr: this.templates.noncestr, // 必填，生成签名的随机串
          signature: this.templates.signature,// 必填，签名
          jsApiList: [
            'updateAppMessageShareData',
            'updateTimelineShareData'
          ], // 必填，需要使用的JS接口列表
          openTagList: [
            'wx-open-subscribe'
          ], // 可选，需要使用的开放标签列表,
        });
      })
    },
    actives(val, name) {
      console.log(name);
      if (name != '未绑定抖音') {
        this.dy_actives = name
        console.log(this.dy_actives);
      } else {
        this.$router.push('/dy_account')
      }
    },
    dy_user_lists() {
      dy_user_list().then(res => {
        console.log(res);
        this.dy_acount = res.Data
        this.dy_actives = res.Data[0].dy_user
        if (res.Data[0] != undefined) {
          this.dy_one = res.Data[0].dy_user
        } else {
          this.dy_one = '未绑定抖音'
        }
        if (res.Data[1] != undefined) {
          this.dy_two = res.Data[1].dy_user
        } else {
          this.dy_two = '未绑定抖音'
        }
        if (res.Data[2] != undefined) {
          this.dy_three = res.Data[2].dy_user
        } else {
          this.dy_three = '未绑定抖音'
        }
        if (res.Data[3] != undefined) {
          this.dy_four = res.Data[3].dy_user
        } else {
          this.dy_four = '未绑定抖音'
        }
        if (res.Data[4] != undefined) {
          this.dy_five = res.Data[4].dy_user
        } else {
          this.dy_five = '未绑定抖音'
        }
      })
    },
    remindes() {
      let str = this.getNum()
      let params = {
        authorized: aestool.encrypt('remind_begin', str),
        authorized_s: aestool.encrypt(str, '123Remindaddress'),
      }
      remindaddress(params).then(res => {
        let temp = aestool.decrypt(res.Data, '123Remindaddress')
        console.log('开启', temp)
        window.location.href = temp
      })
    },
    handleFocus() {
      let str = this.getNum()
      let params = {
        authorized: aestool.encrypt('remind_begin', str),
        authorized_s: aestool.encrypt(str, '123Remindaddress'),
      }
      remindaddress(params).then(res => {
        let temp = aestool.decrypt(res.Data, '123Remindaddress')
        console.log('开启', temp)
        window.location.href = 'https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MzIzMjE3NTE3NA==&scene=124#wechat_redirect'
      })
    },
    queren() {
      console.log(this.evareview_info);
      this.$router.push({
        path: "/evaluate",
        query: {
          baby_id: this.evareview_info.baby_id,
          id: this.evareview_info.task_id,
          order_Id: this.evareview_info.order_num
        }
      })
    },
    wei_go(id) {
      let params = {
        reminder_id: id
      }
      reminder_no(params).then((res) => {
        if (res.Status == 200) {
          this.$toast(res.Message)
          setTimeout(() => {
            this.getStatus()
          }, 2000)
        } else {
          this.$toast(res.Message)
        }
      })
    },
    queren_() {
      this.$router.push('/collection')
    },
    //获取用户信息
    getUserData() {
      getuserinfo()
        .then(res => {
          if (res.data.Status == 200) {
            sessionStorage.setItem('useinfo', aestool.decrypt(res.data.Data, '123456asdzxcqwe0'))
            this.userinfodata = JSON.parse(aestool.decrypt(res.data.Data, '123456asdzxcqwe0'))
            this.taobao_name = this.userinfodata.taobao_name
            console.log(this.userinfodata, '获取用户信息');
            this.tb_one = this.userinfodata.tb_name_list[0]
            if (this.userinfodata.tb_name_list[1] != undefined) {
              this.tb_two = this.userinfodata.tb_name_list[1]
            } else {
              this.tb_two = '未绑定淘宝号'
            }
            if (this.userinfodata.tb_name_list[2] != undefined) {
              this.tb_three = this.userinfodata.tb_name_list[2]
            } else {
              this.tb_three = '未绑定淘宝号'
            }
            if (this.userinfodata.tb_name_list[3] != undefined) {
              this.tb_four = this.userinfodata.tb_name_list[3]
            } else {
              this.tb_four = '未绑定淘宝号'
            }
            if (this.userinfodata.tb_name_list[4] != undefined) {
              this.tb_five = this.userinfodata.tb_name_list[4]
            } else {
              this.tb_five = '未绑定淘宝号'
            }
            if (this.userinfodata.phone == '') {
              this.$router.push('/Top_Lo_Re')
              window.localStorage.removeItem('xfq_token')
            }
            if (this.userinfodata.user_status == 1) {
              this.user_status = true
            }
            if(this.userinfodata.alpay ==''){
              this.ALIplay = true
            }
          }
        })
    },
    timestampToTime(timestamp) {
      var date = new Date(timestamp * 1000);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
      var Y = date.getFullYear() + '-';
      var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
      var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
      var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
      var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
      var s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
      return Y + M + D + h + m + s;
    },
    //获取活动状态
    getStatus() {
      let toastload = this.$toast.loading({
        message: '加载中...',
        forbidClick: true
      });
      getuserstatus().then(res => {
        toastload.clear()
        if (res.data.Status == 200) {
          this.tasktatus = JSON.parse(aestool.decrypt(res.data.Data, '123456asdzxcqwe0'))
          console.log(this.tasktatus, '获取活动状态');
          //自动申请
          if(this.tasktatus.task_status == 1){
            // console.log(this.tasktatus.task_status)
             this.self_motion()
          }
          this.evareview_info = this.tasktatus.evareview_info
          if (this.tasktatus.xxopenid == 1) {
            this.reminds = true
          }
          if (this.tasktatus.evareview_status != 0) {
            this.showshadow = true
          }
          if (this.tasktatus.reminder_status == 1) {
            this.showshadow_ = true
          } else {
            this.showshadow_ = false
          }
          if (this.tasktatus.task_status == 1) {
            this.showwait = false
            this.showready = false
          } else if (this.tasktatus.task_status == 2) {
            this.showwait = true
            this.showready = false
          } else if (this.tasktatus.task_status == 3) {
            this.showwait = false
            this.showready = true
            this.taskprogressing()
          }
        }
      })
    },
    onLoad() {
      this.page++
      let params = {
        page: this.page,
        page_size: 10
      }
      bulletin_list(params).then(res => {
        console.log('通知列表', res)
        if (res.Status == 200) {
          let temp = res.Data
          let ipos
          temp.forEach(item => {
            ipos = item.create_time.indexOf("+")
            item.create_time = item.create_time.replace(/T/g, " ").substring(0, ipos)
            this.listdata.push(item)
          });
        }
        console.log(this.listdata);
      })
    },
    //领取活动
    ondraw(){
      if(this.taskdata.task_class=='dy'){
        let toastload = this.$toast.loading({
          message: '加载中...',
          forbidClick: true
        });
        let str = this.getNum()
        let params = {
          data: aestool.encrypt('Identifytask_4', str),
          data_s: aestool.encrypt(str, '123456asdzxcqwe0'),
        }
        identifytask(params).then(res => {
          toastload.clear()
          if (res.Status == 200) {
            this.showready = false
            this.$toast(res.Message)
            setTimeout(() => {
              this.$router.push('/dy_details')
            }, 1500);
          } else {
            this.$toast(res.Message)
          }
        })
      }else if(this.taskdata.task_class=='pdd'){
        let toastload = this.$toast.loading({
          message: '加载中...',
          forbidClick: true
        });
        let str = this.getNum()
        let params = {
          data: aestool.encrypt('Identifytask_4', str),
          data_s: aestool.encrypt(str, '123456asdzxcqwe0'),
        }
        identifytask(params).then(res => {
          toastload.clear()
          if (res.Status == 200) {
            this.showready = false
            this.$toast(res.Message)
            setTimeout(() => {
              this.$router.push('/dd_details')
            }, 1500);
          } else {
            this.$toast(res.Message)
          }
        })
      }else{
        let toastload = this.$toast.loading({
          message: '加载中...',
          forbidClick: true
        });
        let str = this.getNum()
        let params = {
          data: aestool.encrypt('Identifytask_4', str),
          data_s: aestool.encrypt(str, '123456asdzxcqwe0'),
        }
        identifytask(params).then(res => {
          toastload.clear()
          if (res.Status == 200) {
            this.showready = false
            this.$toast(res.Message)
            setTimeout(() => {
              this.$router.push('/taskdetail')
            }, 1500);
          } else if(res.Message == '好像暂时没有任务需要确认'){
            setInterval(()=>{
              this.$router.go(0)
            },1000)
            this.$toast(res.Message)
          }else{
            this.$toast(res.Message)
          }
        })
      }
    },
    getNum() {
      var chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
      var nums = ""
      for (var i = 0; i < 16; i++) {
        var id = parseInt(Math.random() * 61);
        nums += chars[id];
      }
      return nums
    },
    clickBtn(idx) {
      if (idx == 3) {
        this.checks = 'pdd'
        if (this.userinfodata.pdd_status == 0) {
          this.$toast('请先绑定品拼多多号！')
          setTimeout(() => {
            this.$router.push('/dd_account')
          }, 1500);
        } else if (this.userinfodata.pdd_status == 2) {
          this.$toast('请等待审核通过！')
        } else if (this.userinfodata.pdd_status == 3) {
          this.$toast('您的帐号已冻结！')
        } else {
          this.act = idx
          // this.gettasknum()
        }
      }
      if (idx == 1) {
        this.checks = 'tb'
        if (this.userinfodata.user_status == 1) {
          this.$toast('请完善信息后再申请活动！')
          setTimeout(() => {
            this.$router.push('/uploadImg')
          }, 1500);
        } else if (this.userinfodata.user_status == 3) {
          this.$toast('当前用户已被冻结，请联系客服进行处理！')
        } else if (this.userinfodata.user_status == 4) {
          this.$toast('当前用户资料正在审核中...')
        } else if (this.tasktatus.task_status == 3 || this.tasktatus.task_status == 4) {
          this.$toast('当前有活动进行中，请完成活动后再申请活动！')

        } else {
          this.act = idx
          // this.gettasknum()
        }
      }
      if (idx == 2) {
        this.checks = 'dy'
        if (this.userinfodata.dy_status == 0) {
          this.$toast('请先绑定抖音号！')
          setTimeout(() => {
            this.$router.push('/dy_account')
          }, 1500);
        } else if (this.userinfodata.dy_status == 2) {
          this.$toast('请等待审核通过！')
        } else if (this.userinfodata.dy_status == 3) {
          this.$toast('您的帐号已冻结！')
        } else {
          this.act = idx
          // this.gettasknum()
        }
      }
    },
    taskprogressing() {
      taskprogress().then((res) => {
        if (res.Status == 200) {
          this.taskdata = JSON.parse(aestool.decrypt(res.Data, 'cpf123456tasklis'))
          window.localStorage.setItem('xfq_task_class', this.taskdata.task_class)
        } else {
          this.$toast(res.Message)
        }
      })
    },
    self_motion(){
      let params = {
        task_info: aestool.encrypt('pt', 'cpf814322587mamp'),
        tb_name: this.taobao_name,
      }
      let toastload = this.$toast.loading({
        message: '加载中...',
        forbidClick: true
      });
      submessage(params).then(res => {
        console.log(res);
        toastload.clear()
        if (res.Status == 200) {
          this.$toast(res.Message)
          this.tasktatus.task_status = 2
          this.showwait = true
        } else if (res.Status == 430) {
          this.$toast('请完善信息后再申请活动！')
          setTimeout(() => {
            this.$router.push('/uploadImg')
          }, 1500);
        } else if (res.Status == 400 && res.Code == 265) {
          this.tasktatus.task_status = 2
          this.showwait = true
        } else if(res.Message == '已经接到任务，请确认领取~~'){
          this.$toast(res.Message)
          setInterval(()=>{
            this.$router.go(0)
          },1000)
        }else{
          this.$toast(res.Message)
        }
      })
    },
    //申请活动
    onApply() {
      // return this.accuracyshow = true
      if (this.userinfodata.user_status == 1) {
        this.$toast('请完善信息后再申请活动！')
        setTimeout(() => {
          this.$router.push('/uploadImg')
        }, 1500);
      } else if (this.userinfodata.user_status == 3) {
        this.$toast('当前用户已被冻结，请联系客服进行处理！')
      } else if (this.userinfodata.user_status == 4) {
        this.$toast('当前用户资料正在审核中...')
      } else if (this.tasktatus.task_status == 3 || this.tasktatus.task_status == 4) {
        this.$toast('当前有活动进行中，请完成活动后再申请活动！')
        setInterval(()=>{
          if (this.taskClass == 'dy') {
            this.$router.push('/dy_details')
          } else {
            this.$router.push('/taskdetail')
          }
        },1000)
      } else {
        let toastload = this.$toast.loading({
          message: '加载中...',
          forbidClick: true
        });
        let typetext = '';
        if (this.act == 1) {
          typetext = 'pt';
        } else if (this.act == 2) {
          typetext = 'dy';
        } else if (this.act == 3) {
          typetext = 'pdd';
        }
        if (typetext == 'dy') {
          let params = {
            dy_name: aestool.encrypt(this.dy_actives, 'cpf814322587Name')
          }
          dy_sub_message(params).then((res) => {
            if (res.Status == 200) {
              this.$toast(res.Message)
              this.tasktatus.task_status = 2
              this.showwait = true
            } else {
              this.$toast(res.Message)
            }
          })
        } else {
          let params = {
            task_info: aestool.encrypt(typetext, 'cpf814322587mamp'),
            tb_name: this.taobao_name,
          }
          submessage(params).then(res => {
            console.log(res);
            toastload.clear()
            if (res.Status == 200) {
              this.$toast(res.Message)
              this.tasktatus.task_status = 2
              this.showwait = true
            } else if (res.Status == 430) {
              this.$toast('请完善信息后再申请活动！')
              setTimeout(() => {
                this.$router.push('/uploadImg')
              }, 1500);
            } else if (res.Status == 400 && res.Code == 265) {
              this.tasktatus.task_status = 2
              this.showwait = true
            } else if(res.Message == '已经接到任务，请确认领取~~'){
              this.$toast(res.Message)
              setInterval(()=>{
                this.$router.go(0)
              },1000)
            }else{
              this.$toast(res.Message)
            }
          })
        }
      }
    },
    //取消活动
    oncancel() {
      let toastload = this.$toast.loading({
        message: '加载中...',
        forbidClick: true
      });
      let str = this.getNum()
      let params = {
        queuedata: aestool.encrypt('Cancelqueue_1', str),
        queuedata_s: aestool.encrypt(str, '123456asdzxcqwe0'),
      }
      cancelqueue(params).then(res => {
        toastload.clear()
        // if (res.Status == 200) {
        //   this.showwait = false
        //   this.$toast('取消活动成功！')
        //   this.tasktatus.task_status = 1
        // } else {
        //   this.$toast(res.Message)
        // }
        this.showwait = false
        this.$toast('取消活动成功！')
        this.tasktatus.task_status = 1
      })
    }
  }
}
</script>

<style lang="stylus" scoped>
.home {
  height 100%
  font-size 12px

  .home_bg {
    height 100%
    background url("../assets/img/404.png") no-repeat top center
    background-size cover
  }

  .popupbox {
    padding 20px 50px

    img {
      width 160px
      height 160px
    }

    .icon {
      text-align center
      font-size 60px
      color #07c160
    }

    .isok {
      width 160px
      font-size 14px
      padding 0 0 10px
    }

    .waittext {
      line-height 40px
      text-align center
      font-size 16px
    }

    .btnlist {
      display flex
      justify-content space-between
      align-items center
    }

    .cancel {
      background #64c5ff
      color #ffffff
      border-radius 20px
      line-height 30px
      margin 10px 0
      text-align center
      padding 0 12px
    }
  }

  .apply {
    background url(../assets/img/z_bg.jpg) top center no-repeat
    background-size 70%
    text-align center
    padding-top 48%
  }

  .apply_text {
    color #fff
    border 1px solid #fff
    border-radius 30px
    padding 6px 18px
    font-size 16px
    box-shadow 0px 1px 6px 0px #11a3fb
  }

  .shadow {
    width 300px
    height 380px
    background url(../../static/img/QQ.png) no-repeat top center
    background-size cover
  }

  .shadowing {
    width 300px
    height 380px
    background url(../assets/img/remind.png) no-repeat top center
    background-size cover

    .startBtn {
      height 40px
      background-image linear-gradient(to right, #3b5bea, #5786ff)
      text-align center
      line-height 40px
      color #ffffff
      font-size 16px
      position absolute
      bottom 20px
      margin: 0 25px
      width 250px
      border-radius 20px
    }
  }

  .shadow_ {
    position relative
    width 300px
    height 380px
    background url(../../static/img/QQ_.png) no-repeat top center
    background-size cover
  }

  .startBtn_yes {
    height 40px
    background-image linear-gradient(to right, #3b5bea, #5786ff)
    text-align center
    line-height 40px
    color #ffffff
    font-size 16px
    position absolute
    bottom 20px
    margin: 0 25px
    width 250px
    border-radius 20px
  }

  .startBtn_no {
    height 40px
    background-image linear-gradient(to right, #3b5bea, #5786ff)
    text-align center
    line-height 40px
    color #ffffff
    font-size 16px
    position absolute
    bottom 20px
    margin: 0 165px
    width 100px
    border-radius 20px
  }

  .blocked {
    margin-top 20px
    display flex
    justify-content center
    align-items center
  }

  .btn {
    line-height 40px
    padding 0 30px
    box-shadow 0px 1px 6px 0px #eaeaea
  }

  .same {
    background #fff
    color #8c8c8c
  }

  .left_btn {
    border-top-left-radius 40px
    border-bottom-left-radius 40px
  }

  .center_btn {
    background #fff
    /*color #fdee45*/
  }

  .right_btn {
    border-top-right-radius 40px
    border-bottom-right-radius 40px
  }

  .active {
    background-color #eaeaea
  }

  .bigcard {
    box-shadow 0px 1px 6px 0px #eaeaea
    margin 6% 6% 0
  }

  .card {
    background url(../../static/img/card.png) no-repeat top center
    background-size cover
    text-align left
    padding 20px 12px 60px
    color #fff
    border-top-left-radius 10px
    border-top-right-radius 10px
  }

  .task {
    display block
    line-height 30px
  }

  .special {
    font-size 18px
    padding 0 6px
    color #fdee45
  }

  .visit {
    padding 10px 12px
    border-bottom-left-radius 10px
    border-bottom-right-radius 10px
    text-align left
    color #6b7786
  }

  .back {
    height 100%
    overflow hidden

    .listbox {
      padding 15px
      margin 0 16px 10px
      border-radius 6px
      box-shadow 0px 0px 10px #f6f6f6
      font-size 12px
      background #ffffff
      color #333

      .title {
        display flex
        justify-content space-between
        align-items center
        font-size 16px
        margin 10px 0
      }
    }
  }
}

.waters {
  width 300px
  display: flex
  align-items: center
  justify-content: center
  margin: 15px auto
  height 40px
  //border 1px solid #bababa
}
</style>
<style>
.van-swipe__track {
  width: 100% !important;
}
</style>
